using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using buildingLib;
namespace _dmis
{
    public partial class PetEdit : _dmis.WinPart
    {
        Pet m_pet;
        Owner m_owner;
        public PetEdit(Pet pet,Owner owner)
        {
            InitializeComponent();
            m_pet = pet;
            m_owner = owner;
            petsBindingSource.DataSource = m_pet;
        }

        #region WinPart Code

        protected internal override object GetIdValue()
        {
            return m_pet.ID;
        }

        public override string ToString()
        {
            return m_pet.Doorid.ToString();
        }

        private void ResourceEdit_CurrentPrincipalChanged(object sender, EventArgs e)
        {
            ApplyAuthorizationRules();
        }
        #endregion

        private void ApplyAuthorizationRules()
        {
           
        }

        private void tsb_save_Click(object sender, EventArgs e)
        {
            this.m_owner.Pets.Add(m_pet);
            this.Close();
        }

        private void tsb_close_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void petsBindingSource_CurrentItemChanged(object sender, EventArgs e)
        {
            this.tsb_save.Enabled = m_pet.IsSavable;
        }
    }
}

